Skip to content

Add composite interactions#973

Open
Meklo wants to merge 25 commits intomainfrom
marcellinh/add_composite_interactions
Open

Add composite interactions#973
Meklo wants to merge 25 commits intomainfrom
marcellinh/add_composite_interactions

Conversation

@Meklo
Copy link
Copy Markdown
Contributor

@Meklo Meklo commented Mar 27, 2026

PR Summary

Mathieu-Deharbe and others added 15 commits March 12, 2026 11:30
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ba9fb9ca-16d1-461d-ae82-4d1a44f2dafa

📥 Commits

Reviewing files that changed from the base of the PR and between f858b54 and 9c80bb8.

📒 Files selected for processing (1)
  • src/main/java/org/gridsuite/study/server/service/StudyService.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/org/gridsuite/study/server/service/StudyService.java

📝 Walkthrough

Walkthrough

Adds an endpoint to move a composite sub-modification and implements the backend flow: controller → rebuild layer → study service → network service. Also expands composite UUIDs to leaf UUIDs when excluding modifications and adds tests covering move scenarios and composite expansion.

Changes

Cohort / File(s) Summary
Controller
src/main/java/org/gridsuite/study/server/controller/StudyController.java
Added PUT /studies/{studyUuid}/nodes/{nodeUuid}/composite-sub-modification/{modificationUuid} endpoint with optional sourceCompositeUuid, targetCompositeUuid, and beforeUuid query parameters and standard pre-checks; delegates to rebuild service.
Rebuild / Orchestration
src/main/java/org/gridsuite/study/server/service/RebuildNodeService.java
Added public moveSubModification(...) that wraps move logic in rebuild workflow and new private helper to perform node invalidation, call study move, and ensure unblock in finally.
Study service
src/main/java/org/gridsuite/study/server/service/StudyService.java
Added moveSubModification(...) orchestrator that validates node, resolves modification group, emits notifications, and calls network service. Updated updateNetworkModificationsActivationInRootNetwork(...) to expand composites to leaf UUIDs before excluding.
Network layer
src/main/java/org/gridsuite/study/server/service/NetworkModificationService.java
Added moveSubModification(...) to issue PUT to network composite sub-modifications endpoint with conditional query params, and expandToLeafUuids(...) to GET leaf UUIDs for composite expansions.
Tests
src/test/java/org/gridsuite/study/server/NetworkModificationTest.java
Added testMoveSubModification covering three PUT scenarios validating query parameters and notifications; added testUpdateNetworkModificationsActivationExpandsCompositeToLeafUuids to validate expansion of composite UUIDs to leaf UUIDs and exclusion behavior.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant StudyController
    participant RebuildNodeService
    participant StudyService
    participant NetworkModificationService

    Client->>StudyController: PUT /v1/studies/{studyUuid}/nodes/{nodeUuid}/composite-sub-modification/{modificationUuid}?sourceCompositeUuid=&targetCompositeUuid=&beforeUuid=
    StudyController->>RebuildNodeService: moveSubModification(studyUuid, nodeUuid, sourceCompositeUuid, targetCompositeUuid, modificationUuid, beforeUuid, userId)
    RebuildNodeService->>StudyService: invalidateNodeTreeWhenMoveModification(studyUuid, nodeUuid)
    RebuildNodeService->>StudyService: moveSubModification(..., userId)
    StudyService->>NetworkModificationService: moveSubModification(groupUuid, sourceCompositeUuid, targetCompositeUuid, modificationUuid, beforeUuid)
    NetworkModificationService->>NetworkModificationService: build PUT to /groups/{groupUuid}/sub-modifications/{modificationUuid}?...
    NetworkModificationService-->>NetworkModificationService: execute PUT (no body)
    NetworkModificationService-->>StudyService: return
    StudyService->>StudyService: emit element-updated, end notifications
    RebuildNodeService->>StudyService: unblockNodeTree(studyUuid, nodeUuid)  (finally)
    StudyController-->>Client: 200 OK
Loading

Suggested reviewers

  • SlimaneAmar
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is empty (contains only a template heading), providing no information about the changeset or its purpose. Provide a meaningful description explaining what changes were made, why they were needed, and any important context for reviewers to understand the implementation.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add composite interactions' directly relates to the main changes, which implement new endpoints and methods for moving composite sub-modifications across different levels.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.41.1)
src/main/java/org/gridsuite/study/server/service/StudyService.java

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Base automatically changed from specific-composite-handling to main March 30, 2026 11:16
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (4)
src/main/java/org/gridsuite/study/server/service/NetworkModificationService.java (2)

410-437: Add explicit precondition checks for required UUIDs.

groupUuid and modificationUuid are mandatory for URI expansion; guard them at method entry to fail fast with a clear contract.

♻️ Proposed change
 public void moveSubModification(
         UUID groupUuid,
         UUID sourceCompositeUuid,
         UUID targetCompositeUuid,
         UUID modificationUuid,
         UUID beforeUuid) {
+    Objects.requireNonNull(groupUuid, "groupUuid is required");
+    Objects.requireNonNull(modificationUuid, "modificationUuid is required");
 
     var path = UriComponentsBuilder.fromPath(
             COMPOSITE_PATH + "groups" + DELIMITER
                     + "{groupUuid}" + DELIMITER
                     + "sub-modifications" + DELIMITER
                     + "{modificationUuid}");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/main/java/org/gridsuite/study/server/service/NetworkModificationService.java`
around lines 410 - 437, The method moveSubModification should validate required
UUID parameters up front: add explicit null-check preconditions for groupUuid
and modificationUuid (used in URI expansion) at the start of moveSubModification
and throw a clear IllegalArgumentException (or use Objects.requireNonNull) with
descriptive messages; keep existing optional handling for sourceCompositeUuid,
targetCompositeUuid, and beforeUuid unchanged so the rest of the method can
assume groupUuid and modificationUuid are non-null when building the path and
calling restTemplate.put.

439-450: Short-circuit empty input and return a null-safe set.

For an empty list, this can return immediately without a remote call; also avoid leaking a null body to callers.

♻️ Proposed change
 public Set<UUID> expandToLeafUuids(List<UUID> modificationUuids) {
+    Objects.requireNonNull(modificationUuids, "modificationUuids is required");
+    if (modificationUuids.isEmpty()) {
+        return Set.of();
+    }
+
     var path = UriComponentsBuilder.fromPath(COMPOSITE_PATH + "leaf-uuids")
             .queryParam("uuids", modificationUuids)
             .toUriString();
 
-    return restTemplate.exchange(
+    Set<UUID> body = restTemplate.exchange(
             getNetworkModificationServerURI(false) + path,
             HttpMethod.GET,
             null,
             new ParameterizedTypeReference<Set<UUID>>() { }
-    ).getBody();
+    ).getBody();
+    return body != null ? body : Set.of();
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/main/java/org/gridsuite/study/server/service/NetworkModificationService.java`
around lines 439 - 450, The expandToLeafUuids method should short-circuit when
modificationUuids is empty and always return a non-null Set to callers; change
expandToLeafUuids to check modificationUuids.isEmpty() and return
Collections.emptySet() (or Set.of()) immediately instead of calling
restTemplate.exchange, and after the remote call ensure the result from
restTemplate.exchange(...).getBody() is null-checked and replaced with an empty
Set before returning; reference expandToLeafUuids, COMPOSITE_PATH,
restTemplate.exchange and getNetworkModificationServerURI to locate the changes.
src/test/java/org/gridsuite/study/server/NetworkModificationTest.java (2)

3138-3139: Make move-case query assertions strict (including absent params).

Line 3138 and Line 3154 only assert required params, so these cases can still pass if unwanted query params are forwarded. Assert missing params explicitly.

♻️ Proposed test hardening
-        WireMockUtilsCriteria.verifyPutRequest(wireMockServer, moveSubModifUrlPattern, false, Map.of(
-                "targetCompositeUuid", WireMock.equalTo(targetCompositeUuid.toString())), null);
+        WireMockUtilsCriteria.verifyPutRequest(wireMockServer, moveSubModifUrlPattern, false, Map.of(
+                "targetCompositeUuid", WireMock.equalTo(targetCompositeUuid.toString()),
+                "sourceCompositeUuid", WireMock.absent(),
+                "beforeUuid", WireMock.absent()), null);

...
-        WireMockUtilsCriteria.verifyPutRequest(wireMockServer, moveSubModifUrlPattern, false, Map.of(
-                "sourceCompositeUuid", WireMock.equalTo(sourceCompositeUuid.toString())), null);
+        WireMockUtilsCriteria.verifyPutRequest(wireMockServer, moveSubModifUrlPattern, false, Map.of(
+                "sourceCompositeUuid", WireMock.equalTo(sourceCompositeUuid.toString()),
+                "targetCompositeUuid", WireMock.absent(),
+                "beforeUuid", WireMock.absent()), null);

Also applies to: 3154-3155

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/gridsuite/study/server/NetworkModificationTest.java` around
lines 3138 - 3139, The verifyPutRequest call is only checking required params
and allows unwanted query params to slip through; update the
WireMockUtilsCriteria.verifyPutRequest invocations for moveSubModifUrlPattern
(the call using targetCompositeUuid) and the similar call later to assert absent
params explicitly by adding the expected absent query keys to the Map of
matchers using WireMock.absent() (or the project's equivalent absent matcher)
for keys that must not be forwarded, while keeping
WireMock.equalTo(targetCompositeUuid.toString()) for the required
"targetCompositeUuid".

3211-3216: Assert exact exclusion UUID set, not a superset.

Line 3214 currently accepts any superset. Use exact-set equality so the test fails when unexpected UUIDs are included.

♻️ Proposed assertion tightening
+        Set<UUID> expectedExcluded = new HashSet<>(expandedLeafUuids);
+        expectedExcluded.add(compositeUuid);
         verify(rootNetworkNodeInfoService, times(1)).updateModificationsToExclude(
                 eq(nodeUuid),
                 eq(rootNetworkUuid),
-                argThat((Set<UUID> uuids) -> uuids.contains(compositeUuid)
-                        && uuids.containsAll(expandedLeafUuids)),
+                argThat(expectedExcluded::equals),
                 eq(false));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/gridsuite/study/server/NetworkModificationTest.java` around
lines 3211 - 3216, The test currently allows a superset because argThat checks
contains/composite and containsAll; change the assertion in
NetworkModificationTest so the UUID set is compared for exact equality instead
of subset/superset checks: construct the expected Set<UUID> containing
compositeUuid plus expandedLeafUuids and replace argThat((Set<UUID> uuids) ->
uuids.contains(compositeUuid) && uuids.containsAll(expandedLeafUuids)) with an
argument matcher that calls equals(expectedSet) (or use eq(expectedSet)) when
verifying rootNetworkNodeInfoService.updateModificationsToExclude(...), so
unexpected UUIDs will fail the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/java/org/gridsuite/study/server/service/StudyService.java`:
- Around line 2395-2411: The end notification and emitElementUpdated must run
even if networkModificationService.moveSubModification throws; wrap the call to
networkModificationService.moveSubModification(...) in a try/finally so
notificationService.emitEndModificationEquipmentNotification(studyUuid,
nodeUuid, childrenUuids) and notificationService.emitElementUpdated(studyUuid,
userId) are executed in the finally block; preserve the initial calls to
getChildrenUuids and checkStudyContainsNode, rethrow the exception after the
finally block (or allow it to propagate) so existing error behavior is
unchanged.
- Line 2174: The code in StudyService mutates the caller-provided Set
modificationsUuids in-place; avoid this by creating a new mutable collection for
the expanded UUIDs instead of calling modificationsUuids.addAll(...). Call
networkModificationService.expandToLeafUuids(...) with a copy of the incoming
collection if needed, collect the returned UUIDs into a new Set or List (e.g.,
expandedUuids), then use that new collection for downstream logic; reference the
existing symbols modificationsUuids and
networkModificationService.expandToLeafUuids to locate and replace the in-place
addAll with creation of a fresh collection that merges the original and expanded
results without mutating the parameter.

---

Nitpick comments:
In
`@src/main/java/org/gridsuite/study/server/service/NetworkModificationService.java`:
- Around line 410-437: The method moveSubModification should validate required
UUID parameters up front: add explicit null-check preconditions for groupUuid
and modificationUuid (used in URI expansion) at the start of moveSubModification
and throw a clear IllegalArgumentException (or use Objects.requireNonNull) with
descriptive messages; keep existing optional handling for sourceCompositeUuid,
targetCompositeUuid, and beforeUuid unchanged so the rest of the method can
assume groupUuid and modificationUuid are non-null when building the path and
calling restTemplate.put.
- Around line 439-450: The expandToLeafUuids method should short-circuit when
modificationUuids is empty and always return a non-null Set to callers; change
expandToLeafUuids to check modificationUuids.isEmpty() and return
Collections.emptySet() (or Set.of()) immediately instead of calling
restTemplate.exchange, and after the remote call ensure the result from
restTemplate.exchange(...).getBody() is null-checked and replaced with an empty
Set before returning; reference expandToLeafUuids, COMPOSITE_PATH,
restTemplate.exchange and getNetworkModificationServerURI to locate the changes.

In `@src/test/java/org/gridsuite/study/server/NetworkModificationTest.java`:
- Around line 3138-3139: The verifyPutRequest call is only checking required
params and allows unwanted query params to slip through; update the
WireMockUtilsCriteria.verifyPutRequest invocations for moveSubModifUrlPattern
(the call using targetCompositeUuid) and the similar call later to assert absent
params explicitly by adding the expected absent query keys to the Map of
matchers using WireMock.absent() (or the project's equivalent absent matcher)
for keys that must not be forwarded, while keeping
WireMock.equalTo(targetCompositeUuid.toString()) for the required
"targetCompositeUuid".
- Around line 3211-3216: The test currently allows a superset because argThat
checks contains/composite and containsAll; change the assertion in
NetworkModificationTest so the UUID set is compared for exact equality instead
of subset/superset checks: construct the expected Set<UUID> containing
compositeUuid plus expandedLeafUuids and replace argThat((Set<UUID> uuids) ->
uuids.contains(compositeUuid) && uuids.containsAll(expandedLeafUuids)) with an
argument matcher that calls equals(expectedSet) (or use eq(expectedSet)) when
verifying rootNetworkNodeInfoService.updateModificationsToExclude(...), so
unexpected UUIDs will fail the test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8c7fecd4-b51b-49e7-b24d-2837a2aa36c8

📥 Commits

Reviewing files that changed from the base of the PR and between 62a9a5c and f858b54.

📒 Files selected for processing (5)
  • src/main/java/org/gridsuite/study/server/controller/StudyController.java
  • src/main/java/org/gridsuite/study/server/service/NetworkModificationService.java
  • src/main/java/org/gridsuite/study/server/service/RebuildNodeService.java
  • src/main/java/org/gridsuite/study/server/service/StudyService.java
  • src/test/java/org/gridsuite/study/server/NetworkModificationTest.java

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants